import React from 'react'
import ReactDOM from 'react-dom/client'
import './style/base.scss'

// 由于 antd 组件的默认文案是英文，所以需要修改为中文
// antd本地化处理
// dayjs只要antd组件库安装好后，它就会存在，antd它依赖此库，安装antd它会把dayjs也会安装上
import dayjs from 'dayjs'
import 'dayjs/locale/zh-cn'
import { ConfigProvider } from 'antd'
import zhCN from 'antd/locale/zh_CN'

// redux
import { Provider } from 'react-redux'
import store from './store'
import storage from '@/utils/storage'
import { setUserInfo } from './reducers/user'

// router
import { RouterProvider } from 'react-router-dom'
import router from './router'

// redux持久处理
let userinfo = storage().get('user')
if (userinfo) {
  store.dispatch(setUserInfo(userinfo))
}

// 日期本地化处理
dayjs.locale('zh-cn')

const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement)
root.render(
  <Provider store={store}>
    <ConfigProvider locale={zhCN}>
      <RouterProvider router={router} />
    </ConfigProvider>
  </Provider>
)
